package com.example.kotlinlearn.web

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object ServiceCreatorForWeb {
    private const val BASE_URL = "http://47.94.135.113:8081"

    private val retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create()) //指定解析json数据的库
        .build()

    fun <T> create(serviceClass: Class<T>):T= retrofit.create(serviceClass)

    //简化构建方法
    inline fun <reified T> create():T = create(T::class.java)
}